package com.gitee.jjnnzb.designpatterninspring.common.interceptor;

import com.gitee.jjnnzb.designpatterninspring.common.threadlocal.LogThreadLocal;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

/**
 * Http拦截器
 *
 * @author zjc
 * @author Jjn
 * @since 2020-08-18 19:35
 */
@Slf4j
@Component
public class HttpInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler) throws Exception {
        LogThreadLocal.setThreadLocal(System.currentTimeMillis());
        return true;
    }
}
